<template>
  <div>
    <van-address-list
      v-show="!info.isshow"
      v-model="chosenAddressId"
      :list="list"
      :disabled-list="disabledList"
      disabled-text="以下地址超出配送范围"
      default-tag-text="默认"
      @add="onAdd"
      @edit="onEdit"
      @select='select'
    />
    <v-addressadd v-show="info.isshow" :info="info"></v-addressadd>
    
  </div>
</template>

<script>
import { Toast } from "vant";

import vAddressadd from "./components/AddressAdd";
import { mapActions, mapGetters } from 'vuex';
export default {
  components: {
    vAddressadd
  },
  data() {
    return {
      info: {
        isshow: false
      },
      chosenAddressId:'1',
      // chosenAddressId: this.chosenAddressId?this.chosenAddressId:1,//默认值
      // list:[],
      disabledList: [
        {
          id: "3",
          name: "王五",
          tel: "1320000000",
          address: "浙江省杭州市滨江区江南大道 15 号"
        }
      ]
    };
  },
  methods: {
    onAdd() {
      Toast("新增地址");
        this.info.isshow=true
        // console.log(this.addresslist);
    },
    onEdit(item, index) {
      Toast("编辑地址:" + index);
    
    },
    select(item){
      // this.onelist(item)
      console.log(item);
      sessionStorage.setItem('address',JSON.stringify(item))
      this.$router.go('-1')

      
    },
    ...mapActions({
      getaddresslist:"address/addresslistActions",

      // onelist:"address/oneActions"
    })
  },
  computed:{
    ...mapGetters({
      list:"address/addresslist",
      // chosenid:"address/chosenAddressId"
    })
  },
  mounted(){
    this.getaddresslist()
  }
};
</script>

<style scoped>
.yes {
  width: 340px;
  margin: 0 auto;
  margin-left: 20px;
}
</style>